#pragma once

#include "opencv/cv.h"
#include "DDAutoDelete.h"
#include "DDSafeDelete.h"
#include "DDBufferBlock.h"

#define DKQ_TEST

class ImageMan
{
public:
	ImageMan(void);
	~ImageMan(void);

public:
	int OpenFile(char *pFileName);

#ifdef DKQ_TEST
	int WriteFile(char *pFileName);
#endif

public:
	int AdjustImage(float s1=0,float s2=0,long w=0,long h=0);

public:
	int ImageApproach();

public:
	int Analy(ImageMan* pImg);

private:
	int FindArea();
	int FindContours(void *pImage,unsigned long lImgSize);

private:
	int FitRotate(CvPoint pt1,CvPoint pt2,int k=1);
	int CutImage(CvPoint t,long w,long h);

private:
	int Filter(long* kernel, long Ksize, long Kfactor, long Koffset);

public:
	BOOL m_bShowTime;

public:
	BITMAPFILEHEADER m_xBitFileHead;
	BITMAPINFOHEADER m_xBitInfoHead;

public:
	long m_lImgW,m_lImgH;

public:
	DDBufferBlock2  m_xBufImg;
	DDBufferBlock   m_xBufPro;

public:
	CvPoint m_xPoint[4];

};
